<template>
  <div>
    <h3 @click="clear">文章列表</h3>
    <table border="1" width="80%" align="center">
      <thead>
        <tr>
          <th>序号</th>
          <th>标题</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in articleList" :key="item.id" align="center">
          <td>{{ index + 1 }}</td>
          <td>{{ item.title }}</td>
          <td>
            <button @click="del(index)">删除</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
import useArticleStore from "../store/articleStore";
export default {
  setup() {
    // 创建文章数据存储对象
    const articleStore = useArticleStore();
    const { getArticleList, articleDel,articleList } = articleStore;
    return {
      articleList,
      getArticleList,
      articleDel,
    };
  },
  data(){
    return {
      arr:[1,2,3]
    }
  },
  created() {
    this.getArticleList();
  },
  methods: {
    clear(){
      this.articleList=[];
      console.log(this.articleList,123);
    },
    del(index) {
      this.articleDel(index);
    },
  },
};
</script>

<style>
</style>